<template>
  <div class="add_con_form tl" v-loading="loading">
    <el-dialog
      :close-on-click-modal="false"
      title="修改推荐人"
      :modal-append-to-body="false"
      :visible.sync="visible"
      :show="show"
      :before-close="closeDialog"
      @close="$emit('update:show', false)"
      class="tl size_13"
      width="800px"
    >
      <el-form :model="data" :rules="dataYZ" ref="data" class="mar_top" label-width="120px">
        <el-form-item label="会员账号">
          <el-col :span="12">
            <el-input :placeholder="this.editUser" v-model="data.alipay" :disabled="true" clearable></el-input>
          </el-col>
        </el-form-item>

        <el-form-item label="新推荐人账号" prop="tid_cn">
          <el-col :span="12">
            <el-input placeholder v-model="data.tid_cn" clearable></el-input>
          </el-col>
        </el-form-item>

        <el-form-item>
          <el-button :loading="$store.state.isLoading" size="medium" type="primary" @click.prevent="addUpdate('data')">确定</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<style lang="less" scoped></style>

<script>
export default {
  data() {
    return {
      value: "",
      data: {
        id: "",
        tid_cn: "",
      },
      loading: false,
      dataYZ: {},
      visible: this.show,
    };
  },
  props: {
    show: Boolean,
    editId: String,
    editUser: String,
    clickNum: Number,
  },
  methods: {
    closeDialog() {
      this.visible = false;
    },
    addUpdate(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          var params = {};
          params["id"] = this.data.id;
          params["tid_cn"] = this.data.tid_cn;
          this.$api.getUser.userchangetid(params).then((res) => {
            console.log(res);
            if (res.data.code == 200 && res.data.result != null) {
              this.$emit("parent", "这里刷新父页面");
              this.$fnc.alertSuccess({ text: "编辑成功" }); //成功弹出框
              this.visible = false;
            } else {
              this.$fnc.alertError(res.data.result); //失败弹出框
            }
          });
        }
      });
    },
  },
  watch: {
    show() {
      console.log(this.show);
      this.visible = this.show;
    },
    clickNum(id) {
      this.data.id = this.editId;
      console.log("点击button次数", id);
      console.log("编辑ID=" + this.editId);
      console.log("会员名:", this.editUser);
    },
  },
  mounted() {},
  created() {},
};
</script>
